{extend name="base"}
{block name="title"}亲友团绑定成员查询{/block}
{block name="head"}
<style>
a.input{
  margin: 1px;
  padding: 1px;
  display: inline-block;
  min-height:0;
  line-height:18px;
}
.border-table tbody th{text-align:center; color:#333; font-weight:400; padding-left:5px;}
.border-table{font-size:12px; color:#666;}
.border-table th, .border-table td{padding:0 4px;}
</style>
{/block}
{block name="body"}
<body class="mainbody">
<form>
<!--导航栏-->
<div class="location">
  <a href="javascript:history.back(-1);" class="back"><i class="iconfont icon-up"></i><span>返回上一页</span></a>
  <a href="{:url('index/home')}" class="home"><i class="iconfont icon-home"></i><span>首页</span></a>
  <i class="arrow iconfont icon-arrow-right"></i>
  <span>亲友团绑定成员查询</span>
</div>
<!--/导航栏-->

<!--工具栏-->
<div id="floatHead" class="toolbar-wrap">
  <div class="toolbar">
    <div class="box-wrap">
      <a class="menu-btn"><i class="iconfont icon-more"></i></a>
      {neq name="$title.AUID"  value=""}
      <h6 style="font-size: 20px;">亲友团标识：<span style="color: red;">[{$code1}]{$title.Caption}成员</span></h6><br>
      {/neq}
      <div class="l-list">
        <div class="menu-list">
          <div class="rule-single-select">
            <select name="channel" style="display:none">
              <option value="-1">所有渠道</option>
              {volist name="CHANNELS" id="val"}
              <option value="{$key}"{eq name="channel" value="$key"} selected{/eq}>[{$key}]{$val.Name}</option>
              {/volist}
            </select>
          </div>
          <div class="rule-single-select">
            <select name="kind" style="display:none">
              <option value="-1">所有游戏</option>
              {volist name="GAME_KIND" id="val"}
              <option value="{$key}"{eq name="kind" value="$key"} selected{/eq}>[{$key}]{$val}</option>
              {/volist}
            </select>
          </div>

          <div class="rule-single-select">
            <select name="black" style="display:none">
              <option value="-1">是否黑名单</option>
              <option value="0"{eq name="black" value="0"} selected{/eq}>[0]否</option>
              <option value="1"{eq name="black" value="1"} selected{/eq}>[1]是</option>
            </select>
          </div>
          {neq name="$title.AUID" value=""}
          <div class="rule-single-select">
            <select name="code1" style="display:none">
              {volist name="familycode" id="val"}
              <option value="{$val.Code}" {eq name="code1"  value="$val.Code"} selected{/eq}>[{$val.Code}]{$val.Caption}</option>
              {/volist}
            </select>
          </div>
          {/neq}
          <input type="text" class="input txt" autocomplete="off" name="search" value="{$search|default=''|htmlentities}" placeholder="UserID/GameID/昵称" />

          <input type="text" class="input small" autocomplete="off" name="code2" value="{$code2|default=''|htmlentities}" placeholder="代理GameID" />
          <input type="text" class="input small" autocomplete="off" name="code3" value="{$code3|default=''|htmlentities}" placeholder="群主GameID" />

          <a class="btn-search"><i class="iconfont icon-search"></i></a>
        </div>
      </div>
      <div class="r-list">
        <label style="color:#f00;">合计房卡：{$waste|default=0|number_format}</label>
      </div>
    </div>
  </div>
</div>
<!--/工具栏-->

<!--列表-->
<div class="table-container">
<table class="border-table ltable">
  <tr>
    {neq name="$title.AUID" value=""}
    <td>
      <a class="input" id="mobile">移动成员</a>&nbsp;&nbsp;
      <input type="button" style="float: right;margin-top: 5px;" id="checkAll" value="全选">
    </td>
    {/neq}
    <th>#</th>
    <th>渠道</th>
    <th>游戏</th>
    <th>群号</th>
    <th>群货币</th>
    <th>玩家/头像/昵称/GameID</th>
    <th>所属推广员</th>
    <th>所属群主</th>
    <th>绑定日期</th>
    <th>更新日期</th>
    <th width="60">操作</th>
  </tr>
{empty name="list" && name="$code1"}
  <tr><td colspan="11">Oh~暂无数据!</td></tr>
{else}
  {volist name="list" id="v"}
  <tr data-id="{$v.ID}" data-gid="{$v.GameID}" data-fid="{$v.Code}">
    {neq name="$title.AUID" value=""}
    <td>{eq name="$v.UserID" value= "$title.AUID"}
      <p style="float: right; color: red" >群主</p>
      {else/}
      <input type="checkbox" name="checkbox" style="float: right;" value="{$v.GameID}">
      {/eq}
    </td>
    {/neq}
    <td{eq name="$v.IsBlack" value="1"} style="color:#fff; background:#7F7F7F;"{/eq}>{$v.ID}</td>
    <td>[{$v.Channel}]{$CHANNELS[$v.Channel]['Name'] ?? '--'}</td>
    <td>[{$v.KindID}]{$GAME_KIND[$v.KindID] ?? '--'}</td>
    <td><a target="_blank" href="{:url('index')}?code1={$v.Code}">{$v.Code}</a></td>
    <td>{eq name="v.IsPass" value="1"}<a class="input d">{$v.Gold}</a>{else/}{$v.Gold}{/eq}</td>
    <td class="user-avatar" title="
游戏帐号：{$v.Accounts}&#13
真实姓名：{$v.Compellation}&#13
身份证号：{$v.PassPortID}&#13
手机号码：{$v.RegisterMobile}&#13
    性别：{switch name='$v.Sex'}{case value='1'}男性{/case}{case value='2'}女性{/case}{/switch}&#13
注册时间：{$v.RegisterDate}&#13
注册地址：{$v.RegisterIP}&#13;
登录次数：{$v.GameLogonCount} 次&#13
最后登录时间：{$v.LastLogonDate}&#13
最后登录地址：{$v.LastLogonIP}&#13
"{eq name="$v.UserRight" value="64"} style="background:{$v.IsBoss?'#FFC5A8':'#FFDBC8'}"{/eq}>
      <a target="_blank" href="{:url('user.detail/index')}?UserID={$v.UserID}">
        <img src="{$v.Avatar?:'__STATIC__/houtai/images/dface.png'}" />
      </a>
      <div class="user-box">
        <h4><a target="_blank" class="at_{$v.AccountsType}" href="{:url('user.detail/index')}?UserID={$v.UserID}">{:htmlentities($v.NickName)}</a></h4>
        <i>{$v.GameID}</i>
      </div>
    </td>
    <td class="user-avatar"><!-- 所属推广员 -->
    {gt name="v.AUserID" value="0"}
      <a target="_blank" href="{:url('user.detail/index')}?UserID={$v.AUserID}">
        <img src="{$v.AAvatar?:'__STATIC__/houtai/images/dface.png'}" />
      </a>
      <div class="user-box">
        <h4><a target="_blank" class="at_{$v.AAccountsType}" href="{:url('user.detail/index')}?UserID={$v.AUserID}">{$v.ACompellation}</a></h4>
        <i>{$v.AGameID}</i>
      </div>
    {/gt}
    </td>
    <td class="user-avatar"><!-- 所属群主 -->
    {gt name="v.FUserID" value="0"}
      <a target="_blank" href="{:url('user.detail/index')}?UserID={$v.FUserID}">
        <img src="{$v.FAvatar?:'__STATIC__/houtai/images/dface.png'}" />
      </a>
      <div class="user-box">
        <h4><a target="_blank" class="at_{$v.FAccountsType}" href="{:url('user.detail/index')}?UserID={$v.FUserID}">{$v.FCompellation}</a></h4>
        <i>{$v.FGameID}</i>
      </div>
    {/gt}
    </td>
    <td>{$v.CreateTime}</td>
    <td>{$v.UpdateTime}</td>
    <td>
      {eq name="v.IsPass" value="1"}
        <a class="input a">删除绑定</a>
        <a class="input b">设置属性</a>
      {else/}
        <a class="input c">确认审核</a>
      {/eq}
    </td>
  </tr>
  {/volist}
{/empty}
</table>
</div>
<!--/列表-->

<!--内容底部-->
<div class="page-footer"><div class="btn-wrap">{$list->render()}</div></div>
<!--/内容底部-->

</form>
<script>
$(function () {
//反选
  $("#checkAll").on("click",function(){

    $("[name='checkbox']").each(function(){
      //遍历所有复选框，然后取值进行 !非操作
      $(this).prop("checked", !$(this).prop("checked"));
    })
  });
  //解除绑定
  $('table.ltable a.a').click(function () {
    var id = $(this).parents('tr').data('id')
    console.log("删除绑定", id);
    dialog({
      title: '提示',
      content: '是否删除该绑定?',
      okValue: '确定',
      ok: function () {
        $.post("{:url('MemberDelete')}?id=" + id, function (resp, text, xhr) {
          console.log(resp);
          if (resp.errno == 0) {
            location.reload();
          } else {
            alert(resp.error);
          }
        });
        return false;
      },
      cancelValue: '取消',
      cancel: function () {}
    }).showModal();
  });
  //设置属性
  $('table.ltable a.b').click(function () {
    var id = $(this).parents('tr').data('id');
    console.log("属性", id);
    var url = "{:url('mright')}?id=" + id;
    dialog({
      title: '绑定属性[' + id + ']',
      url: url,
      width: 480,
      height: 290,
      okValue: '确认提交',
      ok: function () {
        var f = $('iframe', this.node);
        var v = $('input', f.contents()).serialize();
        console.log(v);
        $.post(url, v, function (resp, state, xhr) {
          console.log(resp);
          alert(resp.error);
          if (resp.errno == 0) {
            location.reload();
          }
        });
        return false;
      }
    }).showModal();
  });
  //移动成员
  $('#mobile').click(function () {
    var auth_list = [];
    $("input[type='checkbox']:checkbox").each(function () {
      if ($(this).attr("checked")) {
        auth_list.push($(this).attr('value') );
      }
    });
    var str = auth_list.join(',');
    dialog({
      title: '添加亲友团成员',
      content: '<select name="familycode" style="">\n' +
              '<option value="">===所有亲友团===</option>\n' +
              '{volist name="familycode" id="val"}\n' +
              '<option value="{$val.ID}" name="familycode" id="optt" {eq name="familycode"  value="$val.ID"} selected{/eq}>[{$val.Code}]{$val.Caption}</option>\n' +
              '{/volist}\n' +
              '</select>',
      okValue: '确定',
      cancelValue: '取消',
      cancel: function () {},
      ok: function () {
        var p = $('[id="optt"]:selected').val();
        console.log(p);
        $.post("{:url('MemberAdd')}", {
          FamilyID: p,
          GameID: str
        }, function (resp, text, xhr) {
          if (resp.errno == 0) {
            location.reload();
            alert('移动成功');
          } else {
            alert(resp.error);
          }
        });
        return false;
      }
    }).showModal();
  });














  $('table.ltable a.c').click(function () {
    var tr = $(this).parents('tr');
    var id = tr.data('id');
    var fid = tr.data('fid');
    var gid = tr.data('gid');
    console.log('确认用户[' + gid + ']加入群[' + fid + ']?');
    dialog({
      title: '提示',
      content: '确认用户[' + gid + ']加入群[' + fid + ']?',
      okValue: '确定',
      ok: function () {
        $.post("{:url('agreem')}?id=" + id, function (resp, text, xhr) {
          console.log(resp);
          if (resp.errno == 0) {
            location.reload();
          } else {
            alert(resp.error);
          }
        });
        return false;
      },
      cancelValue: '取消',
      cancel: function () {}
    }).showModal();
  });
  
  $('table.ltable a.d').click(function () {
    var tr = $(this).parents('tr');
    var id = tr.data('id');
    var gid = tr.data('gid');
    dialog({
      title: '赠送群货币给玩家[' + gid + ']',
      content: '<input type="text" class="input" placeholder="请输入要赠送的群货币" />',
      okValue: '确定',
      cancelValue: '取消',
      cancel: function () {},
      ok: function () {
        var a = $(this.node);
        var p = $('.input', a);
        var v = p.val();
        console.log(v);
        $.post("{:url('zengGold')}", {id: id, gold: v}, function (resp, text, xhr) {
          console.log(resp);
          alert(resp.error);
          if (resp.errno == 0) {
            location.reload();
          }
        });
        return false;
      }
    }).showModal();
  });
});

function a(){
   $("#" + selName + " option").each(function () {
            $(this).remove();
        });
        $("<option value='0'>请选择</option>").appendTo($("#" + selName));
        if ($("#" + sel).val() == 0) {
        return;
        }
        jQuery.getJSON(url, {pid: jQuery("#" + sel).val(), type: type_id}, function (data) {
            console.log(data);
        if (data) {
        jQuery.each(data, function (idx, item) {
        $("<option value=" + item.id + ">" + item.name + "</option>").appendTo($("#" + selName));
        });
        } else {
        $("<option value='0'>请选择</option>").appendTo(jQuery("#" + selName));
        }
        }
    );

  $.ajax({
            //请求方式
            type : "POST",
            //请求的媒体类型
            contentType: "application/json;charset=UTF-8",
            //请求地址
            url : "http://127.0.0.1/admin/list/",
            //数据，json字符串
            data : {},
            //请求成功
            success : function(result) {
                console.log(result);
            },
            //请求失败，包含具体的错误信息
            error : function(e){
                console.log(e.status);
                console.log(e.responseText);
            }
        });
  $(function() {  
    //页面初始，加载所有的省份  
    $.ajax({  
        type: "get",  
        url: "getRegion",
        data: {"type":1},  
        
        dataType: "json",  
        success: function(data) {  
            //遍历json数据，组装下拉选框添加到html中
            $("#provinces").html("<option value=''>请选择省</option>");  
            $.each(data, function(i, item) {  
                $("#provinces").append("<option value='" + item.province_num + "'>" + item.province_name + "</option>");  
            });
        }  
    });  
 
    //监听省select框
    $("#provinces").change(function() {  
        $.ajax({  
            type: "get",  
            url: "getRegion",
            data: {"pid": sel,"type":type_id},  
            dataType: "json",  
            success: function(data) {  
                //遍历json数据，组装下拉选框添加到html中
                $("#citys").html("<option value=''>请选择市</option>");  
                $.each(data, function(i, item) {  
                    $("#citys").append("<option value='" + item.city_num + "'>" + item.city_name + "</option>");  
                });  
            }  
        });  
    });  
 
    //监听市select框
    $("#citys").change(function() {  
        $.ajax({  
            type: "get",  
            url: "getRegion",
            data: {"pid": sel,"type":type_id},  
            dataType: "json",  
            success: function(data) {  
                //遍历json数据，组装下拉选框添加到html中
                $("#countys").html("<option value=''>请选择区</option>");  
                $.each(data, function(i, item) {  
                    $("#countys").append("<option value='" + item.id + "'>" + item.area_name + "</option>");  
                });  
            }  
        });  
    });  
}); 
}
</script>
</body>
{/block}